@extends('layouts.backend')
@section('title')
文章列表
@endsection

@section('body')
<div class="row">
    <div class="ibox">
        <div class="ibox-title">
            <h5>文章列表</h5>
        </div>
        <div class="ibox-content">
            <div class="row">

                <div class="col-md-6">
                    <form role="form" class="form-inline" method="get">
                        <div class="form-group">
                            <input type="text" placeholder="Enter Keyword " value="{{request('keyword', '')}}" name="keyword" id="keyword" class="form-control">

                        </div>
                        <button class="btn btn-primary" type="submit">搜索</button>
                        <a href="{{ route('backend.article.index') }}" class="btn btn-warning">重置</a>
                        <a href="{{route('backend.article.create')}}" class="btn btn-primary m-md">写文章</a>
                    </form>
                </div>


            </div>
            <table class="table">
                <thead>
                <tr>
                    <th>#</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>状态</th>
                    <th>分类</th>
                    <th>Tag</th>
                    <th>访问</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @forelse($articles as $article)
                <tr>
                    <td>{{$article->id}}</td>
                    <td width="350">{{$article->title}}</td>
                    <td><img src="{{get_aether_upload_url($article->page_image)}}" alt="" class="img-thumbnail img-md"></td>
                    <td>
                        @if($article->is_draft)
                            <span class="badge badge-primary">已发布</span>
                        @else
                            <span class="badge badge-danger">草稿</span>
                        @endif
                    </td>
                    <td><span class="badge badge-success">{{optional($article->category)->name}}</span></td>
                    <td>
                        @forelse($article->tags as $tag)
                            <span class="badge badge-primary">{{$tag->tag}}</span>
                        @empty
                        @endforelse
                    </td>
                    <td>{{$article->view_count}}</td>
                    <td>{{$article->created_at}}</td>
                    <td>
                        <a href="{{route('backend.article.edit', $article)}}" class="btn btn-primary btn-sm">编辑</a>
                        <a href="{{route('backend.article.content', $article)}}" class="btn btn-warning btn-sm">编辑内容</a>
                        <a href="{{route('backend.article.publish', $article)}}" class="btn btn-success btn-sm">发布</a>
                        @include('components.backend.destroy', ['url' => route('backend.article.destroy', $article)])
                    </td>
                </tr>
                @empty
                <tr>
                    <td class="text-center" colspan="7">暂无记录</td>
                </tr>
                @endforelse
                </tbody>
            </table>
        </div>
        <div class="ibox-footer">
            {{$articles->render()}}
        </div>
    </div>
</div>
@endsection
